package cn.yunhe.spring.util;

import java.lang.reflect.Field;
import java.lang.reflect.Method;

public class BeanUtil {

	public static Method getSetterMethod(Object object, String name) {
		Method method = null;

		String methodName = "set" + name.substring(0, 1).toUpperCase()
				+ name.substring(1);
		try {
			Field f = object.getClass().getDeclaredField(name);
			method = object.getClass().getMethod(methodName,
					new Class[] { f.getType() });
		} catch (Exception e) {
			throw new RuntimeException("属性名称不合法或者没有相应的getter方法：" + name);
		}
		return method;
	}

}
